﻿using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using facebook.Components;
using facebook.desktop.Properties;
using facebook.Schema;
using System.Net;

namespace facebook.desktop
{
    public partial class CreateAlbum : Form
    {
        facebook.Components.FacebookService fbserv;
        album newalb;
        const int maxphotsnmberinalbum = 37;

        public album NewAlbum
        {
            get { return newalb; }

        }
        
        public CreateAlbum(facebook.Components.FacebookService Facebooksrv)
        {
            InitializeComponent();
            fbserv = Facebooksrv;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CreateAlbum_Load(object sender, EventArgs e)
        {

        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                if((fbserv !=null ) &&(txtAlbumName.Text !=null) 
                    &&(openFile.ShowDialog()==DialogResult.OK ) &&(openFile.FileName !=null))
                {
                   newalb =fbserv.photos.createAlbum(txtAlbumName.Text,txtLocation.Text,txtCaption.Text);
                   
                   
                        
                    foreach(string file in openFile.FileNames )
                    {
                        if(file!=null)
                        {
                            //Bitmap pic = new Bitmap(file);
                            FileInfo fileinf = new FileInfo(file);
                            fbserv.photos.upload(newalb.aid, null, fileinf);

                        }

                    }
                    
                   
                }

                
                this.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());

            }
        }
    }
}
